dataviz\figure\datasets/cartesiangraphdataset.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
use crate::figure::utilities::linetype::LineType;
/// A dataset for Cartesian graphs, representing data points and line appearance properties.
pub struct CartesianDataset {
/// A collection of `(x, y)` data points for the Cartesian graph.
pub points: Vec<(f64, f64)>,
/// Color of the line in RGB format.
pub color: [u8; 3],
/// Label for the dataset, used in legends or annotations.
pub label: String,
/// Style of the line (solid, dashed, dotted).
pub line_type: LineType,
}
impl CartesianDataset {
/// Creates a new `CartesianDataset` instance with the specified appearance and metadata.
///
/// # Parameters
/// - `color`: The RGB color of the line.
/// - `label`: A descriptive label for the dataset.
/// - `line_type`: The style of the line (`LineType`).
///
/// # Returns
/// A new `CartesianDataset` instance with an empty list of points.
///
/// # Example
/// ```rust
/// use crate::figure::utilities::linetype::LineType;
///
/// let dataset = CartesianDataset::new([0, 128, 255], "Temperature", LineType::Dashed(10));
/// ```
pub fn new(color: [u8; 3], label: &str, line_type: LineType) -> Self {
Self {
points: Vec::new(),
color,
label: label.to_string(),
line_type,
}
}
}